
package matchingPLS2TF;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;


public class Main2FlickrData3_2 {

	
	public static void main (String [] args) throws Exception{
		//continene tutti gli utenti  
		List<FlickrUser> f = new ArrayList<FlickrUser>();
		FlickrUserMethods.loadFlickrUser2(f, "TO_bbox/FlicrUsers3EventsTS2106-3107.csv");
		
		Collections.sort(f);
		
		for (int i = 0; i < f.size(); i++) {
			System.out.println(f.get(i).toString());
		}
		
		
	    Map<FlickrUser, List<PLSUser>>	data = new HashMap<FlickrUser, List<PLSUser>>();
	    Set<String> excluded = new HashSet<String>();
	    
	    
		List<PLSUser> pls_user ;
		for (int i = 0; i < f.size(); i++) {
			System.out.println(f.get(i).username);
		}
		Collections.sort(f);
		//FlickrUserMethods.printUserTsAndCoord("FlickrUsersTsAndCoord.csv", f);
	
		for (int i = 0; i < f.size(); i++) {	
		
			//pls_user = new ArrayList<PLSUser>();
			if((f.size() -(i+1))==0){
				break;
			}
			String username_i1 = f.get(i+1).username;
			String username_i = f.get(i).username;
			
			System.out.println(username_i);
			
				double fl_lat = f.get(i).lat;
				double fl_lon = f.get(i).lon;
				
				System.out.println("***********"+fl_lat+", "+fl_lon);
				long ts_flickr_user = f.get(i).timest;
				pls_user = new ArrayList<PLSUser>();
				System.out.println("****** "+f.get(i).username+" ha timestamp = "+ts_flickr_user);
				Object[] o = FlickrUserMethods2.ts_pls_list4FlickrUser("C:/DATA/data/mese/AllData",
						fl_lat, fl_lon, ts_flickr_user);
				
				pls_user = (List<PLSUser>)o[0];
				data.put(f.get(i), pls_user);
				
				excluded.addAll((Set<String>)o[1]);
				
				
				
				if(!(username_i.equals(username_i1))){
					FlickrUserMethods.print("Twitter2PLSResults_"+username_i+", "+i+"_10min.txt", data);
					System.out.println("stampo file per "+username_i);
					FlickrUserMethods.print("Twitter2PLSExcluded_"+username_i+", "+i+"_10min.txt", excluded);
					System.out.println("stampo file esclusione per "+username_i);
					
					// cancello per prepararmi al prossimo utente
					data = new HashMap<FlickrUser, List<PLSUser>>();
					excluded = new HashSet<String>();
				}
			}
				
	    
	    
    }
}
